package com.my.jli.Service.impl;

import com.my.jli.Service.ScoreService;
import com.my.jli.dao.ScoreRepository;
import com.my.jli.entity.Score;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName ScoreServiceImpl
 * @Description
 * @Author MaYu
 * @Date 2022/5/13 20:47
 * @Version 1.0
 **/
@Service
public class ScoreServiceImpl implements ScoreService {

    private ScoreRepository scoreRepository;
    @Autowired
    public void setScoreRepository(ScoreRepository scoreRepository) {
        this.scoreRepository = scoreRepository;
    }

    @Override
    @Transactional(readOnly = true)
    public List<Score> getAll() {
        return scoreRepository.findAll();
    }

    @Override
    @Transactional(readOnly = true)
    public Score getBySid(Integer sid) {
        return scoreRepository.findBySid(sid);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Score saveScore(Score score) {
        return scoreRepository.save(score);
    }
}
